﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Simple.Repository.Models
{
    /// <summary>
    /// 班级动态留言表
    /// </summary>
    public class ClassDynamicLeaveMessage : BusinessFullEntityBase<Guid>
    {

        /// <summary>
        /// 留言内容
        /// </summary>
        public string? LeaveMessageContent { get; set; }

        /// <summary>
        /// 留言时间
        /// </summary>
        public DateTime? LeaveMessageTime { get; set; }

        /// <summary>
        /// 留言人id
        /// </summary>
        public string? LeaveMessageUserId { get; set; }

        /// <summary>
        /// 留言人姓名
        /// </summary>
        public string? LeaveMessageUserName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public ClassDynamic ClassDynamic = new ClassDynamic();

        /// <summary>
        /// 班级动态Id
        /// </summary>
        public Guid? ClassDynamicId { get; set; }

        /// <summary>
        /// 所在班级id
        /// </summary>
        public Guid? ClassId { get; set; }

        /// <summary>
        /// 回复列表
        /// </summary>
        public List<LeaveMessageReply> Replys = new List<LeaveMessageReply>();

        /// <summary>
        /// 是否回复
        /// </summary>
        public bool IsReply { get; set; } = false;

        /// <summary>
        /// 是否发布
        /// </summary>
        public bool IsPublish {get; set; } = true;

        /// <summary>
        /// 家长或老师标识
        /// </summary>
        public int? LoginType { get; set; }

        /// <summary>
        /// 家属关系
        /// </summary>
        public int? Relationship { get; set; }

        /// <summary>
        /// 关联幼儿Id
        /// </summary>
        public Guid? RelationshipChildrenId { get; set; }

        /// <summary>
        /// 留言人图片Id
        /// </summary>
        public string? LeaveMessageUserImageId { get; set; }

        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<ClassDynamicLeaveMessage>(entity =>
            {
                entity.ToTable("Class_DynamicLeaveMessage");
                entity.HasOne(c => c.ClassDynamic).WithMany(c => c.LeaveMessages).HasForeignKey(c => c.ClassDynamicId);
            });
        }

    }
}
